package com.report.controller;

import cn.hutool.core.convert.Convert;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.report.dto.request.InsightReq;
import com.report.dto.response.InsightRes;
import com.report.dto.response.ReportRes;
import com.report.entity.Report;
import com.report.service.IReportService;
import com.report.service.InsightService;
import com.zmh.framework.config.BaseCommonInterface;
import com.zmh.framework.util.Result;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author summer
 * @since 2024/06/27 16:24:42
 */
@RestController
@RequestMapping("/insight")
@AllArgsConstructor
public class InsightController implements BaseCommonInterface<InsightReq, InsightRes> {


    private final InsightService insightService;

    @Override
    public Result<String> save(@Valid InsightReq insightReq) {
        insightService.saveInsight(insightReq);

        return Result.successResult();
    }

    @Override
    public Result<String> del(Integer id) {
        insightService.removeById(id);
        return Result.successResult();
    }

    @Override
    public Result<Page<InsightRes>> lists(InsightReq insightReq) {
        Page<InsightRes> page=insightService.lists(insightReq);
        return Result.successResult(page);
    }

    @Override
    public Result<InsightRes> findById(Integer id) {
        InsightRes insightRes = Convert.convert(InsightRes.class, insightService.getById(id));
        return Result.successResult(insightRes);
    }

    @Override
    public Result<String> batchDel(List<InsightRes> list) {
        return null;
    }

    private final IReportService reportService;

    @GetMapping(value = "/findReport")
    public Result<List<ReportRes>> findReport(){
        List<ReportRes>  lists= reportService.finBreStateReport();
        return Result.successResult(lists);
    }
}
